package QQTest;
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
public class QQLogin extends JFrame implements ActionListener{
	JPanel jp1,jp2,jp3;
	JLabel jl1,jl2,jl3,jl4,jl5;
	JTextField jtf;
	JPasswordField jpf;
	JButton jt1,jt2;

	public QQLogin() {
		jp1=new JPanel();
		jp2=new JPanel();
		jp3=new JPanel();
		jl1=new JLabel(new ImageIcon("images\\tou.jpg"));
		jl2=new JLabel("QQ号码：",JLabel.CENTER);
		jl3=new JLabel("<html><a href='www.qq.com'>申请号码</a></html>",JLabel.CENTER);
		jl4=new JLabel("QQ密码：",JLabel.CENTER);
		jl5=new JLabel("<html><a href='www.qq.com'>忘记密码</a></html>",JLabel.CENTER);
		jtf=new JTextField(15);
		jpf=new JPasswordField(15);
		jt1=new JButton("登录");
		jt2=new JButton("取消");
		this.setLayout(new BorderLayout());
		jp1.setLayout(new FlowLayout());
		jp2.setLayout(new GridLayout(2,3,0,5));
		jp3.setLayout(new FlowLayout());
		jp1.add(jl1);
		jp2.add(jl2);
		jp2.add(jtf);
		jp2.add(jl3);
		jp2.add(jl4);
		jp2.add(jpf);
		jp2.add(jl5);
		jp3.add(jt1);
		jp3.add(jt2);
		this.add(jp1,BorderLayout.NORTH);
		this.add(jp2);
		this.add(jp3,BorderLayout.SOUTH);
		this.setTitle("QQ2010");
	    ImageIcon icon=new ImageIcon("images\\qq.jpg");
	    this.setIconImage(icon.getImage());//给窗体设置图标
		this.setLocation(300, 200);
		this.setSize(350,200);
		this.setResizable(false);
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		this.setVisible(true);
		jt1.addActionListener(this);
		jt2.addActionListener(this);
}
		@Override
	    public void actionPerformed(ActionEvent e) {
			if(e.getActionCommand().equals("登录")) {
				String str1=new String(jtf.getText());
				char[] cs=jpf.getPassword();
				String str2=new String(cs);
				if(str1.equals("5201314") && str2.equals("060121"))
			    	System.out.println("QQ号和密码正确");
				else
					System.out.println("QQ号或密码不正确");
			}
			else if(e.getActionCommand().equals("取消"))
			jtf.setText(null);
			jpf.setText(null);
		    }


	public static void main(String[] args) {
		QQLogin qqLogin = new QQLogin();

	}
}

